package puzzle.projecteuler.p100;

public class Problem085 {

	/**
	 * C(m+1,2) * C(n+1,2)
	 * @param args
	 */
	public static void main(String[] args) {
		int D = 2000000;
		int a = 0;
		for (int m = 1; m < 2000; m ++) {
			int cm = (m+1)*m/2;
			for (int n = 1; n < 2000; n ++) {
				int cn = (n+1)*n/2;
				int d = 2000000 - cm*cn;
				if (d < 0) {
					break;
				} else if (d < D) {
					D = d;
					a = m*n;
				}
			}
		}
		System.out.println(D);
		System.out.println(a);
	}

}
